<?php
class Blog_model extends CI_Model {

    public function __construct()
    {
        $this->load->database();
    }

    public function getTotal()
    {
        $count = $this->db->count_all('blog');
        return $count;
    }

    public function getBlogNowPage($perPage, $firstRow)
    {
        $query = $this->db->get('blog', $perPage, $firstRow);
        /**
         * 这里的第2,3位参数是limit, 但和原生limit顺序相反
         * $query = $this->db->get('mytable', 10, 20);  Executes: SELECT * FROM mytable LIMIT 20, 10
         */
        return $query->result_array();
    }
}